#if !SERVER
using Net.Client;
using Net.Share;
using UnityEngine;

namespace Example2
{
    public class PlayerIdle : ActorStateBase<Player>
    {
        public override void OnUpdate()
        {
            if (!self.IsLocal)
                return;
            Vector3 moveDirection;
            if (InputJoystick.Direction != Vector3.zero)
                moveDirection = InputJoystick.Direction;
            else
                moveDirection = InputEx.Direction;
            var direction = Camera.main.transform.Transform3Dir(moveDirection);
            if ((Input.GetKeyDown(KeyCode.Space) || InputJump.IsJump) & self.isGround)
            {
                ChangeState(3);
            }
            if (direction != Vector3.zero)
            {
                ChangeState(1);
            }
            if (Input.GetMouseButtonDown(0) || InputFire.IsFire)
            {
                ChangeState(2);
            }
        }
    }

    public class PlayerRun : ActorStateBase<Player>
    {
        public override void OnUpdate()
        {
            if (!self.IsLocal)
                return;
            Vector3 moveDirection;
            if (InputJoystick.Direction != Vector3.zero)
                moveDirection = InputJoystick.Direction;
            else
                moveDirection = InputEx.Direction;
            var direction = Camera.main.transform.Transform3Dir(moveDirection);
            if ((Input.GetKeyDown(KeyCode.Space) || InputJump.IsJump) & self.isGround)
            {
                ChangeState(3);
            }
            if (direction != Vector3.zero)
            {
                transform.rotation = Quaternion.Lerp(transform.rotation, Quaternion.LookRotation(direction, Vector3.up), 0.5f);
                transform.Translate(0, 0, self.Property.MoveSpeed * Time.deltaTime);
            }
            if (Input.GetMouseButtonDown(0) || InputFire.IsFire)
            {
                ChangeState(2);
            }
        }
    }

    public class PlayerFire : ActorStateBase<Player>
    {
        public override void OnEnter()
        {
            base.OnEnter();
            self.AddOperation(new Operation(Command.Fire, self.Identity)
            {
                position = self.firePoint.position,
                rotation = self.firePoint.rotation,
            });
        }
    }

    public class PlayerJump : ActorStateBase<Player>
    {
        public override void OnEnter()
        {
            base.OnEnter();
            self.rigidbody.AddForce(transform.up * self.jumpSpeed);
        }
    }

    public class PlayerDeath : ActorStateBase<Player>
    {

    }
}
#endif